/*
Pascal's Triangle II

Given an index k, return the kth row of the Pascal's triangle.

For example, given k = 3,
Return [1,3,3,1].

Note:
Could you optimize your algorithm to use only O(k) extra space?
*/

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <sstream>
#include "print.h"
using namespace std;

/**
* Definition for binary tree*/


void testForStack()
{
	stack<int> mystack;
	mystack.push(10);
	mystack.push(20);
	mystack.top() -= 5;
	cout << "mystack.top() is now " << mystack.top() << endl;
}

void testForIntToString()
{
	int a = 10;
	stringstream ss;
	ss << a;
	string str = ss.str();
	cout << str << endl;

	string str1 = to_string(a);

}




class Solution {
public:
	vector<int> getRow(int rowIndex) {
		
		vector<int> reslult(0);
		int endInt = 0;
		int pre, cur;;

		if (rowIndex == 0)
		{
			reslult.push_back(1);
			return reslult;
		}else if (rowIndex == 1)
		{
			reslult.push_back(1);
			reslult.push_back(1);

			return reslult;
		}
		else
		{
			reslult.push_back(1);
			reslult.push_back(1);

			for (int i = 2; i <= rowIndex; i++)
			{
				endInt = reslult[reslult.size() - 1];
				reslult.push_back(endInt);
				pre = reslult[0];

				for (int j = 1; j < reslult.size() - 1; j++)
				{
					cur = reslult[j];
					reslult[j] += pre;
					pre = cur;
				}

			}

		}
		return reslult;
		

		

		
		
	}
};

int main(int argc, char* argv[])
{

	int n = 0;

	for (int i = 1; i < argc; i++){


		cout << argv[i] << endl;
		n = atoi(argv[i]);
	}

	 vector<int> a;
	Solution s;
	//stackTree.push(p->left);
	//stackTree.push(p->right);
	//cout << " The longest path:" << s.maxDepth(p) << endl;

	a = s.getRow(n);

	system("pause");
	return 0;
}